<?php
session_start();
$login_type = $_SESSION['login_type'];//登录类型
$login = unserialize($_SESSION['login_user']);
if ($login == '' || $login == null) {
    header("Location: login.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>成绩管理系统-首页</title>
    <link rel="stylesheet" href="css/index.css">
</head>
<body>
<div class="head">
    <p>成绩管理系统</p>
    <p><?php if ($login_type==1) echo $login['username']; else echo $login['name']?> 欢迎! <a href="action/del_session.php">【安全退出】</a></p>
</div>
<div class="border">
    <div class="content">
        <div class="nav">
            <button class="accordion"><img src="images/student.ico" alt="" width="32px" height="32px">学生管理</button>
            <div class="panel">
                <a href="view/student.php" target="info">查看信息</a><br>
                <a href="view/edit_student.php" target="info" class="<?php echo $login_type != 1 ? 'hidden' : '' ?>">添加学生</a><br>
            </div>
            <button class="accordion <?php echo $login_type == 0 ? 'hidden' : '' ?>"><img src="images/grade.ico" alt=""
                                                                                          width="32px" height="32px">班级管理
            </button>
            <div class="panel <?php echo $login_type == 0 ? 'hidden' : '' ?>">
                <a href="view/grade.php" target="info">查看班级</a><br>
                <a href="view/edit_grade.php" target="info"
                   class="<?php echo $login_type == 2 ? 'hidden' : '' ?>">添加班级</a><br>
            </div>
            <button class="accordion <?php echo $login_type != 1 ? 'hidden' : '' ?>"><img src="images/teacher.ico"
                                                                                          alt="" width="32px"
                                                                                          height="32px">教师管理
            </button>
            <div class="panel <?php echo $login_type != 1 ? 'hidden' : '' ?>">
                <a href="view/teacher.php" target="info">查看教师</a><br>
                <a href="view/edit_teacher.php" target="info">添加教师</a><br>
            </div>
            <button class="accordion <?php echo $login_type != 1 ? 'hidden' : '' ?>"><img src="images/course.ico" alt=""
                                                                                          width="32px" height="32px">课程管理
            </button>
            <div class="panel <?php echo $login_type != 1 ? 'hidden' : '' ?>">
                <a href="view/course.php" target="info">查看课程</a><br>
                <a href="view/edit_course.php" target="info">添加课程</a><br>
            </div>
            <button class="accordion"><img src="images/score.ico" alt="" width="32px" height="32px">分数统计</button>
            <div class="panel">
                <a href="view/score.php" target="info">查看分数</a><br>
                <a href="view/add_score.php" class="<?php echo $login_type != 2 ? 'hidden' : '' ?>" target="info">登记分数</a><br>
            </div>
            <button class="accordion"><img src="images/sezhi.ico" alt="" width="32px" height="32px">系统设置</button>
            <div class="panel">
                <a href="view/announ_info.php" target="info">公告</a><br>
                <a href="view/password.php" target="info">密码修改</a>
            </div>
            <button class="accordion"><img src="images/file.ico" alt="" width="32px" height="32px">文件显示</button>
            <div class="panel">
                <a href="show_file.php" target="info">显示所有文件</a><br>
            </div>
        </div>
        <script>
            var acc = document.getElementsByClassName("accordion");
            var i;

            for (i = 0; i < acc.length; i++) {
                acc[i].onclick = function () {
                    this.classList.toggle("active");
                    var panel = this.nextElementSibling;
                    if (panel.style.maxHeight) {
                        panel.style.maxHeight = null;
                    } else {
                        panel.style.maxHeight = panel.scrollHeight + "px";
                    }
                }
            }
        </script>

        <iframe src="view/welcome.php" name="info" frameborder="0"></iframe>
    </div>
</div>
<div class="footer">
    <div class="ico">
        Copyright &copy; 2019-<?php date_default_timezone_set('PRC');
        echo date('Y') ?> HXB_DreamMav版权所有
    </div>
    <!--访问量-->
    <div class="img">
        <?php
        $f = file_get_contents("conf/visitor.txt");
        for ($i = 0; $i < strlen($f); $i++) {
            $index = substr($f, $i, 1);   //截取单个字符
            ?>
            <img src=<?php echo 'images/v' . $index . '.png' ?> width="28" class="img-responsive">
            <?php
        }
//        echo $_SESSION['visitor'];
        if ($_SESSION['visitor']==1) {
            unset ($_SESSION['visitor']);//销毁
            file_put_contents("conf/visitor.txt", $f + 1);
        }

        ?>
    </div>
</div>

</body>
</html>